module.exports = (arr, sameKey, mergeKey) => {
  const result = []
  const temp = {}
  for (const i in arr) {
    const key = arr[i][sameKey]
    if (temp[key]) {
      // eslint-disable-next-line no-self-assign
      temp[key][sameKey] = temp[key][sameKey]
      for (let j = 0; j < mergeKey.length; j++) {
        temp[key][mergeKey[j]] = temp[key][mergeKey[j]] + arr[i][mergeKey[j]]
      }
    } else {
      temp[key] = {}
      temp[key][sameKey] = arr[i][sameKey]
      for (let j = 0; j < mergeKey.length; j++) {
        temp[key][mergeKey[j]] = arr[i][mergeKey[j]]
      }
    }
    // 不用合并的值
  }
  for (const k in temp) {
    result.push(temp[k])
  }
  return result
}
